$(document).ready(function ()
{
    /**
     * 浏览器检测脚本
     * @author : nonglei
     * @date   : 16/09/2014
     */
    detectBrowserScript();

    $("#close-warning").click(function(){
        $(".browser-waring").slideUp("normal");
    });
    /**
     * change the display of topbutton with the scrolltop
     * @author : nonglei
     * @date   : 29/08/2014
     */
    $(window).scroll(function ()
    {
        if($(window).scrollTop() <= 100)
        {
            $("#top-button").hide();
        }
        else
        {
            $("#top-button").show();
        }
    });
    passTime();
});

function passTime()
{
    var num = parseInt($('#timepass').text());
    num = num + 1;
    var day = parseInt(num / (24 * 3600));
    var hour = parseInt(num % (24 * 3600) /3600);
    var min = parseInt(num % (24 * 3600) % 3600 / 60);
    var sec = parseInt(num % (24 * 3600) % 3600 % 60);
    var time = day + "天" + hour + "小时" + min +"分" + sec + "秒";
    $('#timepass').text(num);
    $('#formattimepass').text(time);
	setTimeout("passTime()",1000)
}
function detectBrowserScript()
{
    var explorer = getExplorerInfo().type;
    var version = getExplorerInfo().version;
    if(explorer == "IE" && version < 8)
    {
        $(".browser-waring").slideDown("normal");
    }
}

function getExplorerInfo() {
    var explorer = window.navigator.userAgent.toLowerCase() ;
    //ie
    if (explorer.indexOf("msie") >= 0) {
        var ver=explorer.match(/msie ([\d.]+)/)[1];
        return {type:"IE",version:ver};
    }
    //firefox
    else if (explorer.indexOf("firefox") >= 0) {
        var ver=explorer.match(/firefox\/([\d.]+)/)[1];
        return {type:"Firefox",version:ver};
    }
    //Chrome
    else if(explorer.indexOf("chrome") >= 0){
        var ver=explorer.match(/chrome\/([\d.]+)/)[1];
        return {type:"Chrome",version:ver};
    }
    //Opera
    else if(explorer.indexOf("opera") >= 0){
        var ver=explorer.match(/opera.([\d.]+)/)[1];
        return {type:"Opera",version:ver};
    }
    //Safari
    else if(explorer.indexOf("Safari") >= 0){
        var ver=explorer.match(/version\/([\d.]+)/)[1];
        return {type:"Safari",version:ver};
    }
}

